<table class="datagrid">
  <thead class="datagrid">
    <tr>
      <th>Description</th>
      <th>Amount</th>
      <th>Discounts</th>
      <th>Subtotal</th>
      <th></th>
      <th style="width:16px;"></th>
    </tr>
  </thead>
  <tbody id="gridInvoiceAmounts" class="datagrid" style="height:75px;">
    <?php $total['subtotal'] = 0;?>
    <?php $amountCount = count($invoiceAmountss)?>
    <?php foreach($invoiceAmountss as $invoiceAmounts):?>
    <tr>
      <td>
        <?php if($invoiceAmounts->getInvoice()->getDocument()->getVoid() == 'N'):?>
        <?php 
          echo 
            link_to(
              $invoiceAmounts->getDescription(),
              'invoice/editInvoiceAmounts?invoice_iden='.$invoiceAmounts->getInvoiceIden().'&amount_iden='.$invoiceAmounts->getAmountIden()
            );
        ?>
        <?php else:?>
        <?php echo $invoiceAmounts->getDescription() ?>
        <?php endif;?>
      </td>
      <td style="text-align:right;"><?php echo number_format($invoiceAmounts->getAmount(),2);?></td>
      <td>
        <?php echo $invoiceAmounts->getDiscount1();?>%
        <?php echo $invoiceAmounts->getDiscount2();?>%
        <?php echo $invoiceAmounts->getDiscount3();?>%
        <?php echo $invoiceAmounts->getDiscount4();?>%
      </td>
      <td style="text-align:right;">
        <?php echo number_format($invoiceAmounts->getSubtotal(),2);?>
      </td>
      <td>
        <?php if($invoiceAmounts->getInvoice()->getDocument()->getVoid() == 'N'):?>
        <?php if($amountCount>1):?>
        <?php 
          echo 
            link_to(
              'Delete',
              'actionVerifier/verify?'.
                'task=invoiceAmountsDelete'.
                  '&invoice_iden='.$invoiceAmounts->getInvoiceIden().
                  '&amount_iden='.$invoiceAmounts->getAmountIden().
                  '&cancel_callback=invoiceDeleteVerified('.json_encode(array('invoice_iden'=>$invoiceAmounts->getInvoiceIden(),)).',\'\')'.
                  '&callback=invoiceDeleteVerified'.
                  '&prompt=Delete invoice amount: "'.$invoiceAmounts->getDescription().'" with amount '.$invoiceAmounts->getAmount().'.'
            );
        ?>
        <?php endif;?>
        <?php endif;?>
      </td>
      <td></td>
    </tr>
    <?php $total['subtotal'] += $invoiceAmounts->getSubtotal();?>
    <?php endforeach; ?>
  </tbody>
  <tfoot class="datagrid">
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td style="text-align:right;"><?php echo number_format($total['subtotal'],2);?></td>
      <td></td>
      <td></td>
    </tr>
  </tfoot>
</table>